package cn.outsourcing.supermarket.controller.backstage;

import cn.outsourcing.supermarket.common.Result;
import cn.outsourcing.supermarket.common.utils.ResultUtils;
import cn.outsourcing.supermarket.dto.AdminMemoDTO;
import cn.outsourcing.supermarket.dto.backstage.BackstageChangeStatusDTO;
import cn.outsourcing.supermarket.dto.backstage.BackstageDeliveryDTO;
import cn.outsourcing.supermarket.dto.backstage.BackstageEditOrderPriceDTO;
import cn.outsourcing.supermarket.dto.backstage.BackstageSaveGoodsListDTO;
import cn.outsourcing.supermarket.service.BackstageOrderService;
import cn.outsourcing.supermarket.service.HiolabsAdminService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 订单列表控制器
 *
 * @author gzkemays
 * @since 2021/11/3 2:09
 */
@RestController
@RequestMapping("/admin/order")
public class OrdersController {
  @Resource BackstageOrderService backstageOrderService;
  @Resource HiolabsAdminService adminService;

  @PostMapping("/saveAdminMemo")
  public Result saveAdminMemo(@RequestBody AdminMemoDTO dto) {
    return ResultUtils.simpleResult(adminService.orderMemo(dto));
  }

  @GetMapping("/detail")
  public Result getOrderDetail(@RequestParam("orderId") Integer orderId) {
    return ResultUtils.simpleResult(backstageOrderService.getOrdersDetail(orderId));
  }

  @GetMapping("/orderPrice")
  public Object editOrderPrice(BackstageEditOrderPriceDTO dto) {
    return ResultUtils.simpleResult(backstageOrderService.editPrice(dto));
  }

  @PostMapping("/changeStatus")
  public Result changeStatus(@RequestBody BackstageChangeStatusDTO dto) {
    return ResultUtils.simpleResult(backstageOrderService.changeStatus(dto));
  }

  @PostMapping("/saveGoodsList")
  public Result saveGoodsList(@RequestBody BackstageSaveGoodsListDTO dto) {
    return ResultUtils.simpleResult(backstageOrderService.saveGoodsList(dto));
  }

  @PostMapping("/goDelivery")
  public Result goDelivery(@RequestBody BackstageDeliveryDTO dto) {
    return ResultUtils.simpleResult(backstageOrderService.goDelivery(dto));
  }
}
